import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/deal_entity.dart';

DealEntity $DealEntityFromJson(Map<String, dynamic> json) {
  final DealEntity dealEntity = DealEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    dealEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    dealEntity.msg = msg;
  }
  final List<DealData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DealData>(e) as DealData).toList();
  if (data != null) {
    dealEntity.data = data;
  }
  return dealEntity;
}

Map<String, dynamic> $DealEntityToJson(DealEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension DealEntityExtension on DealEntity {
  DealEntity copyWith({
    int? code,
    String? msg,
    List<DealData>? data,
  }) {
    return DealEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

DealData $DealDataFromJson(Map<String, dynamic> json) {
  final DealData dealData = DealData();
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    dealData.title = title;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    dealData.name = name;
  }
  final String? sellPrice = jsonConvert.convert<String>(json['sell_price']);
  if (sellPrice != null) {
    dealData.sellPrice = sellPrice;
  }
  final String? traTime = jsonConvert.convert<String>(json['tra_time']);
  if (traTime != null) {
    dealData.traTime = traTime;
  }
  return dealData;
}

Map<String, dynamic> $DealDataToJson(DealData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['title'] = entity.title;
  data['name'] = entity.name;
  data['sell_price'] = entity.sellPrice;
  data['tra_time'] = entity.traTime;
  return data;
}

extension DealDataExtension on DealData {
  DealData copyWith({
    String? title,
    String? name,
    String? sellPrice,
    String? traTime,
  }) {
    return DealData()
      ..title = title ?? this.title
      ..name = name ?? this.name
      ..sellPrice = sellPrice ?? this.sellPrice
      ..traTime = traTime ?? this.traTime;
  }
}